﻿Imports System.Data
Imports Cls_Common
Imports VSModel

Partial Class FrontEnd_Control_QuangCao_Slider
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim lstNode As New DataSet
            lstNode.ReadXml(MapPath("../../../xml/SliderLeft.xml"))
            With rptMenu
                .DataSource = lstNode.Tables("Node")
                .DataBind()
            End With
            ShowImagesAdvers()
        End If
    End Sub
    Protected Sub rptMenu_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptMenu.ItemDataBound
        Dim hplTitle As HyperLink = CType(e.Item.FindControl("hplTitle"), HyperLink)
        hplTitle.NavigateUrl = MainDomain & e.Item.DataItem("URL").ToString
        hplTitle.Text = e.Item.DataItem("Title")
    End Sub
    Protected Sub ShowImagesAdvers()
        Using Data As New VSEntities
            Dim p = (From q In Data.ImagesAdvers Where q.StatusID = 3 And q.Subject = ImageAdverType.BannerHome Select q Order By q.Sort).ToList
            With rptImagesAdvers
                .DataSource = p
                .DataBind()
            End With
        End Using
    End Sub

    Protected Sub rptImagesAdvers_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptImagesAdvers.ItemDataBound
        Dim row As VSModel.ImagesAdver = CType(e.Item.DataItem, VSModel.ImagesAdver)
        Dim hplImages As HyperLink = CType(e.Item.FindControl("hplImages"), HyperLink)
        hplImages.NavigateUrl = row.URL
        Dim imgSRC As Image = CType(e.Item.FindControl("imgSRC"), Image)
        imgSRC.ImageUrl = row.SRC
        imgSRC.ToolTip = row.Title
        'Dim ltrDescription As Literal = CType(e.Item.FindControl("ltrDescription"), Literal)
        'ltrDescription.Text = row.Description
    End Sub
End Class
